package com.wondream.jenkins.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
 
@Component
public class EnvironmentUtils implements ApplicationContextAware {
 
    private static Environment environment;
 
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        EnvironmentUtils.environment = applicationContext.getEnvironment();
    }
 
    public static String getProperty(String key) {
        return environment.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return environment.getProperty(key, defaultValue);
    }
}